import React, { Component } from 'react'
import './comment-items.css';
import PropTypes from 'prop-types'

class CommentItems extends Component {
    constructor(props){
        super(props)
        this.mydel =this.mydel.bind(this);
    }

    mydel(){
        if (window.confirm("你确定删除")) {
            const { delcomment,index } = this.props
            delcomment(index);
        }
       
    }
    render() {
        const { comment } = this.props
        return (
            <li className="list-group-item">
                <div className="handle">
                    <a href="#" onClick={this.mydel} >删除</a>
                </div>
                <p className="user"><span >{comment.username}</span><span>说:</span></p>
                <p className="centence">{comment.content}</p>
            </li>
        )
    }
}
CommentItems.propTypes={
    comment:PropTypes.object.isRequired,
    delcomment:PropTypes.func.isRequired,
    index:PropTypes.number.isRequired
}

export default CommentItems
